package com.stylefeng.guns.rest.common.accesslog;

import com.stylefeng.guns.common.persistence.dao.OperationLogMapper;
import com.stylefeng.guns.common.persistence.model.OperationLog;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

@Slf4j
@Component("accessLog")
public class AsyncAccessLog {


    @Autowired
    private OperationLogMapper operationLogMapper;

    @Async("optLogAsync")
    public void logOpt(OperationLog operationLog) {
        try {
            operationLogMapper.insert(operationLog);
        } catch (Exception e) {
            log.error("记操作日志表失败", e);
        }

    }

}
